<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <title>收货地址</title>
  <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <meta name="apple-mobile-web-app-capable" content="no" />
  <meta name="format-detection" content="telephone=no">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/base.css">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/personalCenter.css">
</head>

<body>
<form id="addressForm" method="post">
<input id="contextPath" type="hidden" value="${pageContext.request.contextPath}">
<input id="addressID" type="hidden" value="${id}">
<input id="status" type="hidden" value="${status}">
<input id="address" type="hidden" value="${provinceName}${cityName}${countryName}">
<input type="hidden" id="goodsId" name="goodsId" value="${goodsId}">
<input type="hidden" id="buyNum" name="buyNum" value="${buyNum}">
<input type="hidden" id="spec" name="spec" value="${spec }">
<input type="hidden" id="type" name="type" value="${type }">
<input type="hidden" id="addressId" name="addressId">
</form>
  <div class="ui_cells">
    <div class="ui_cell">
      <div class="ui_cell_bd">
        <input class="ui_input" id="deliveryName" value="${name}" placeholder="请输入收货人姓名" type="text">
      </div>
    </div>
  </div>
  <div class="ui_cells">
    <div class="ui_cell">
      <div class="ui_cell_bd">
        <input class="ui_input" id="deliveryPhone" value="${phone}" placeholder="请输入您的手机号" type="number">
      </div>
    </div>
  </div>
  <div class="ui_cells">
    <div class="ui_cell" id="select_address">
      <div class="ui_cell_bd rel">
        <!-- <input id="addressData" class="ui_input" readonly placeholder="请填写您的所在区域" value="${provinceName}${cityName}${countryName}" type="text"> -->
        <span id="addressData" class="ui_input"></span>        
        <input type="hidden" id="cityIDList" value="${cityIDList}">
        <input type="hidden" id="cityid">
        <input type="hidden" id="cityName">
        <i class="icon_address_right"></i>
      </div>
    </div>
  </div>
  <div class="ui_cells">
    <div class="ui_cell">
      <div class="ui_cell_bd">
        <input class="ui_input" id="addressDetail" value="${addressDetail}" placeholder="请填写收货人详细地址" type="text">
      </div>
    </div>
  </div>
   <div class="ui_cells">
    <div class="ui_cell data_checkbox">
      <div class="ui_cell_hd g9">设为默认地址</div>
      <div class="ui_cell_bd  f0 tr">
        <a  id="checkStatus" class="simulation_checkbox vm" href="javascript:;"></a>
        <span class="dib_vm"></span>
      </div>
    </div>
  </div>
  <div class="ui_cells">
    <div class="ui_cell login_submit">
      <div class="ui_cell_bd">
        <a class="ui_btn ui_btn_primary btn_login_submit db tc" id="submitClick" onclick="addSave();" href="javascript:;"></a>
      </div>
    </div>
  </div>
	 <script src="${pageContext.request.contextPath}/static/js/lib/jquery/jquery.min.js"></script>
  	 <script src="${pageContext.request.contextPath}/static/js/lib/layer/layer.js"></script>
  	 <script src="${pageContext.request.contextPath}/static/js/lib/form.js"></script>
  	 	 <script src="${pageContext.request.contextPath}/static/js/wap/main-addPAddress.js"></script>
  	 <!-- 地区选择 start -->
  <script src="${pageContext.request.contextPath}/static/js/lib/layer/layer.js"></script>
  <script src="${pageContext.request.contextPath}/static/js/lib/address/data.js?v=654321"></script>
  <script src="${pageContext.request.contextPath}/static/js/lib/picker.js"></script>
  <script src="${pageContext.request.contextPath}/static/js/lib/address/chain.js"></script>
  <script src="${pageContext.request.contextPath}/static/js/lib/address/address.js"></script>
  <script src="${pageContext.request.contextPath}/static/js/lib/menu.js"></script>
  <!-- 地区选择 end -->
  <script type="text/javascript">
  var btn = document.getElementById('select_address');
  
  address_default(btn)

  // 判断是否选择了地址
  function address_default(ele) {
    var input = ele.querySelector('.ui_input');
    if (input.innerHTML.trim() !== '请填写您的所在区域') {
      input.classList.remove('select_address--defeult')
    } else {
      input.classList.add('select_address--defeult')
    }
  }
  
  
  var defaultVal = ["110000", "110100", "110101"]; //默认地区
  btn.addEventListener('click', function() {
	var self = this;
    var input = this.querySelector('.ui_input');
    layer.open({
      type: 1,
      content: '<div id="app"></div>',
      anim: 0,
      style: 'position:fixed; bottom:0; left:0; width:100%; height:280px; padding:0px 0; border:none;',
      success: function(ly) {
        var dd = new Selects('#app', {
          data: city,
          columns: 3,
          value: defaultVal
        });
        var cancel = document.querySelector('.btn__cancel'),
          complete = document.querySelector('.btn__complete');
        // 确定
        complete.addEventListener('click', function() {
          var el = document.querySelectorAll('.scroller-item-selected'),
            name = '',
            val = [];
          [].forEach.call(el, function(ele) {
            name += ele.innerHTML.replace('--', '') + ' ';
            val.push(ele.getAttribute('data-value').replace('--', ''));
          });
          input.innerHTML = name;
          defaultVal = val;
          
          address_default(self)
          $("#cityid").val(defaultVal);
          $("#cityName").val(name);
          layer.closeAll();
        }, false);
        cancel.addEventListener('click', function() {
          layer.closeAll();
        }, false);

      }
    });
  }, false);
  </script>
</body>  
</html>
